$(document).ready(function() {

    // 创建追溯图容器
    ECOTree.IMAGE_PATH = '/bi21/script/';
    var width = document.body.clientWidth,
        height = document.body.clientHeight;
    adjustH = $('#traceInfo').outerHeight();//调整高度
    jQuery.traceGraphic.createTraceContainer({
        parentContainer : $('#traceContainer')[0],
        obj : 'traceGraphic1',// 对象，保存到ECOTree中，供鼠标操作节点时使用
        width : width,
        height : height,
        adjustH : adjustH,// 调整高度，指其他区域所占的高度
        adjustW : 0// 调整宽度，指其他区域所占的宽度
	});
	
	/**
	 * 药品查询参数
	 */
	var searchParams = {};
	var drugData;//药品数据
	var batchData;//批次数据
	
    //清空输入框内容
    $('#prodAttrInput').val('请输入信息');
    $('#prodName').val('');
    $('#batchNo').val('');
    
	bindEvent('prodAttrInput');
	bindEvent('prodName');
	bindEvent('batchNo');
	
	/**
	 * 绑定事件
	 */
	function bindEvent(id) {
        if (!id) {
            return;
        }

        var queue = [];
        var element = $('#' + id),
            fn = function() {
                if (id == 'prodAttrInput') {// 生产企业
                    if (element.val() == '请输入信息' || $.trim(element.val()) == '') {
                        return;
                    }
                    filterData(id);
                } else {
                    filterQueryData(id);
                }
            };
        element.bind("focus", fn);
        element.bind("keyup", fn);
    }
    
	
  
   
    /**
	 * 查询按钮点击事件
	 */
    $("#searchBtn").click(function() {
//    	if(!searchParams.prodSeqNo || !searchParams.entSeqNo || !searchParams.batchNo){
//    		return;
//    	}
        ECOSupport.mask();
        var searchUrl = 'drugTraceAction!getTraceJsonData.action?';
        var params = {
            prodSeqNo : searchParams.prodSeqNo,
            entSeqNo : searchParams.entSeqNo,
            batchNo : searchParams.batchNo,
            entInfoSeqNo : searchParams.entInfoSeqNo
        };
        var data = [{
            "areaCode" : "320412",
            "collapsed" : "",
            "companyId" : "2c9194c71d007ba0011d1de977b606c0",
            "companyName" : "江苏聚荣制药集团有限公司",
            "exwarehouse" : "38170--",
            "id" : "2c9194c71d007ba0011d1de977b606c0",
            "inventory" : "0",
            "lineCode" : "",
            "lineLevel" : "",
            "location" : "江苏省常州市武进区",
            "nodeInflowLineDesc" : "",
            "nodeInflowType" : "3",
            "nodeType" : "1",
            "parentExwarehouse" : "0",
            "pid" : "",
            "pkgUnit" : "盒",
            "provdesc" : "",
            "showTip" : "",
            "storage" : "38170++"
        }, {
            "areaCode" : "",
            "collapsed" : "",
            "companyId" : "6d95c16fd7ce43f1a2aafac31326b7a0",
            "companyName" : "上海九州通医药有限公司",
            "exwarehouse" : "1585",
            "id" : "6d95c16fd7ce43f1a2aafac31326b7a0",
            "inventory" : "33330",
            "lineCode" : "#1675978",
            "lineLevel" : "1",
            "location" : "",
            "nodeInflowLineDesc" : "",
            "nodeInflowType" : "",
            "nodeType" : "2",
            "parentExwarehouse" : "6000",
            "pid" : "2c9194c71d007ba0011d1de977b606c0",
            "pkgUnit" : "",
            "provdesc" : "",
            "showTip" : "",
            "storage" : "600"
        },{
            "areaCode" : "",
            "collapsed" : "",
            "companyId" : "6d95c16fd7ce43f1a2aafac31326b7a0",
            "companyName" : "liuxiaolong",
            "exwarehouse" : "1585",
            "id" : "6d95c16fd7ce43f1a2aafac31326b7a0",
            "inventory" : "33330",
            "lineCode" : "#1675978",
            "lineLevel" : "1",
            "location" : "",
            "nodeInflowLineDesc" : "",
            "nodeInflowType" : "",
            "nodeType" : "2",
            "parentExwarehouse" : "6000",
            "pid" : "2c9194c71d007ba0011d1de977b606c0",
            "pkgUnit" : "",
            "provdesc" : "",
            "showTip" : "",
            "storage" : "600"
        }];
		
		
        // 加载追溯图
        jQuery.traceGraphic.loadTrace({
            data : data
        });
    });
    
   
});